package xcmg.device.dao.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import xcmg.device.dao.entity.purchase.BillStockDO;
import xcmg.device.dao.entity.purchase.PurchaseRequestDO;
import xcmg.device.service.vo.purchase.PurchaseRequestVO;
import xcmg.device.service.vo.purchase.TimelinessReportParamVO;
import xcmg.device.service.vo.purchase.TimelinessReportVO;
import xcmg.device.service.vo.purchase.exportPurchaseVO;

import java.util.List;

@Mapper
public interface PurchaseRequestMapper {
    int deleteByPrimaryKey(String billId);

    int insert(PurchaseRequestDO record);

    PurchaseRequestDO item(String billId);

    PurchaseRequestDO itemByPurchase(@Param("billNo") String billNo, @Param("purchaseOrgId") String purchaseOrgId);

    PurchaseRequestDO itemByBillNo(@Param("billNo") String billNo);

    PurchaseRequestDO itemBySapBillNo(@Param("sapBillNo") String sapBillNo, @Param("purchaseOrgId") String purchaseOrgId);

    int update(PurchaseRequestDO record);

    int updateShipInfo(PurchaseRequestDO record);

    int updateBySaleBill(PurchaseRequestDO record);

    List<PurchaseRequestDO> list(PurchaseRequestVO record);
    
    List<PurchaseRequestDO> getAuditList(PurchaseRequestVO record);

    List<PurchaseRequestDO> listByStatus(PurchaseRequestVO record);


    List<exportPurchaseVO> listforExport(PurchaseRequestVO record);

    Integer checkPendingCount(@Param("orgId")String orgId);

    List<PurchaseRequestDO> addressList(PurchaseRequestVO purchaseRequest);

    int updateDirectAddEnable(@Param("billId") String billId, @Param("isDirectAdd") Integer isDirectAdd);

    int updateSendStatus(@Param("billId") String billId, @Param("sendStatus") Integer sendStatus);

    int updatePrintState(@Param("billId") String billId, @Param("printState") Integer printState);

    int updateInboundStatus(@Param("billId") String billId, @Param("status") Integer status);

    List<String> selectIdForCrm(String orgId);

    List<TimelinessReportVO> timelinessReport(TimelinessReportParamVO timelinessReportParamVO);
    
    String getBillNoBySourceNo(String sourceOrder);
    
    int selectUnStockCount(String soldOrgId);
    
    List<String> listUnStockInfos(@Param("soldOrgId") String soldOrgId, @Param("startNum") Integer startNum, @Param("endNum") Integer endNum);

    int mergeIntoStockInfo(BillStockDO billStockDO);
    
    List<BillStockDO> selectStockInfoByBillNo(String billNo);

    Integer getDeliveryCount(@Param("vo") exportPurchaseVO vo);
}
